package com.stlm2.dems.entity;

/**
 * Created by apple on 2017.11.24.
 */
public enum ExpressCompany {
    YuanTong(1, "yuantong"),
    ShenTong(2, "shentong"),
    HuiTongKuaiDi(3, "huitongkuaidi"),
    ZhongTong(4, "zhongtong"),
    YunDa(5, "yunda"),
    YouZhengGuoNei(6, "youzhengguonei"),
    TianTian(7, "tiantian"),
    ShunFeng(8, "shunfeng"),
    EMS(9, "ems"),
    ZhaiJiSong(10, "zhaijisong"),
    QuanFengKuaiDi(11, "quanfengkuaidi"),
    DeBangKuaiDi(12, "debangwuliu");


    private final int val;
    private final String desc;

   ExpressCompany(int val, String desc) {
        this.val = val;
        this.desc = desc;
    }

    public String toString(){
        return desc;
    }

    /**
     * 获得快递公司代码
     * @return
     */
    public String getCom(){
        return this.name().toLowerCase();
    }

    public int getIntValue() {
        return val;
    }

    public static ExpressCompany getByName(String name) {
        if ("yuantong".equals(name)) {
            return YuanTong;
        } else if ("shentong".equals(name)) {
            return ShenTong;
        } else if ("huitongkuaidi".equals(name)) {
            return HuiTongKuaiDi;
        } else if ("zhongtong".equals(name)) {
            return ZhongTong;
        } else if ("yunda".equals(name)) {
            return YunDa;
        } else if ("youzhengguonei".equals(name)) {
            return YouZhengGuoNei;
        } else if ("tiantian".equals(name)) {
            return TianTian;
        } else if ("shunfeng".equals(name)) {
            return ShunFeng;
        } else if ("ems".equals(name)) {
            return EMS;
        } else if ("zhaijisong".equals(name)) {
            return ZhaiJiSong;
        } else if ("quanfengkuaidi".equals(name)) {
            return QuanFengKuaiDi;
        } else if ("debangwuliu".equals(name)) {
            return DeBangKuaiDi;
        }
        return null;
    }

    public static ExpressCompany getByIntValue(int n) {
        switch (n) {
            case 1:
                return YuanTong;
            case 2:
                return ShenTong;
            case 3:
                return HuiTongKuaiDi;
            case 4:
                return ZhongTong;
            case 5:
                return YunDa;
            case 6:
                return YouZhengGuoNei;
            case 7:
                return TianTian;
            case 8:
                return ShunFeng;
            case 9:
                return EMS;
            case 10:
                return ZhaiJiSong;
            case 11:
                return QuanFengKuaiDi;
            case 12:
                return DeBangKuaiDi;
            default:
                return null;
        }
    }
}
